package cn.com.dhc.danlu.widget.adapter;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import cn.com.dhc.danlu.fragment.EnvelopFragment;

/**
 * @author wuhaiyang
 */
public class EnvelopeFragmentAdapter extends FragmentPagerAdapter {
    public static final int TYPE_ENVELOP_STATUS = 0; //我的优惠券
    public static final int TYPE_ENVELOP_USE = 1;//使用优惠券

    private int mType;

    private String[] mStatusTitles = new String[]{
            "未使用", "已使用", "已过期"
    };
    private String[] mUseTitlse = new String[]{
            "可用红包", "不可用红包"
    };


    public EnvelopeFragmentAdapter(FragmentManager fm, int type) {
        super(fm);
        this.mType = type;
    }

    @Override
    public Fragment getItem(int index) {
        Bundle bundle = new Bundle();
        bundle.putInt("index", index);
        bundle.putInt("type", mType);
        return EnvelopFragment.newInstance(bundle);
        //后期根据需求添加对应的fragment
    }

    @Override
    public int getCount() {
        return mType == TYPE_ENVELOP_STATUS ? mStatusTitles.length : mUseTitlse.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mType == TYPE_ENVELOP_STATUS ? mStatusTitles[position] : mUseTitlse[position];
    }
}